package com.hqyj.javaGraduation.hotel.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hqyj.javaGraduation.hotel.pojo.UserTableInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.DeleteMapping;

@Mapper
@Repository
public interface UserTableDao extends BaseMapper<UserTableInfo> {

    // 客户预定座位
    @Insert("insert into user_table_info (user_id,table_id,ut_reserve_date,ut_phone) values(#{userTableInfo.userId}" +
            ",#{userTableInfo.tableId},#{userTableInfo.utReserveDate},#{userTableInfo.utPhone})")
    int insertUserReserveTable(@Param("userTableInfo") UserTableInfo userTableInfo);

    // 取消座位预定
    @Delete("delete from user_table_info where ut_id = #{userTableInfo.utId}")
    int deleteUserReserveTableByUserTableInfo(@Param("userTableInfo") UserTableInfo userTableInfo);

    // 客户在预定时间内到达
    @Update("update user_table_info set ut_state = #{userTableInfo.utState} where ut_id = #{userTableInfo.utId}")
    int updateUserReserveTable(@Param("userTableInfo") UserTableInfo userTableInfo);
}
